import { IPSThreshold } from './ipsthreshold';
import { IPSThresholdGroup } from './ipsthreshold-group';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { IPSDEDataSet } from '../dataentity/ds/ipsdedata-set';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSThresholdGroupImpl extends PSModelObjectImpl implements IPSThresholdGroup {
  protected beginvaluepsdefield: IPSDEField | null = null;

  getBeginValuePSDEField(): IPSDEField | null {
    if (this.beginvaluepsdefield != null) return this.beginvaluepsdefield;
    const value = this.M.getBeginValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.beginvaluepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.beginvaluepsdefield;
  }

  get beginValuePSDEField(): IPSDEField | null {
    return this.getBeginValuePSDEField();
  }

  getBeginValuePSDEFieldMust(): IPSDEField {
    const value = this.getBeginValuePSDEField();
    if (value == null) {
      throw new Error('未指定开始值存储属性');
    }
    return value;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  protected datapsdefield: IPSDEField | null = null;

  getDataPSDEField(): IPSDEField | null {
    if (this.datapsdefield != null) return this.datapsdefield;
    const value = this.M.getDataPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.datapsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.datapsdefield;
  }

  get dataPSDEField(): IPSDEField | null {
    return this.getDataPSDEField();
  }

  getDataPSDEFieldMust(): IPSDEField {
    const value = this.getDataPSDEField();
    if (value == null) {
      throw new Error('未指定阈值数据存储属性');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected endvaluepsdefield: IPSDEField | null = null;

  getEndValuePSDEField(): IPSDEField | null {
    if (this.endvaluepsdefield != null) return this.endvaluepsdefield;
    const value = this.M.getEndValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.endvaluepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.endvaluepsdefield;
  }

  get endValuePSDEField(): IPSDEField | null {
    return this.getEndValuePSDEField();
  }

  getEndValuePSDEFieldMust(): IPSDEField {
    const value = this.getEndValuePSDEField();
    if (value == null) {
      throw new Error('未指定结束值存储属性');
    }
    return value;
  }

  protected iconclspsdefield: IPSDEField | null = null;

  getIconClsPSDEField(): IPSDEField | null {
    if (this.iconclspsdefield != null) return this.iconclspsdefield;
    const value = this.M.getIconClsPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.iconclspsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.iconclspsdefield;
  }

  get iconClsPSDEField(): IPSDEField | null {
    return this.getIconClsPSDEField();
  }

  getIconClsPSDEFieldMust(): IPSDEField {
    const value = this.getIconClsPSDEField();
    if (value == null) {
      throw new Error('未指定图标样式值存储属性');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdedataset: IPSDEDataSet | null = null;

  getPSDEDataSet(): IPSDEDataSet | null {
    if (this.psdedataset != null) return this.psdedataset;
    const value = this.M.getPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.psdedataset = ipsdataentity.findPSDEDataSet(value);
    }
    return this.psdedataset;
  }

  get psDEDataSet(): IPSDEDataSet | null {
    return this.getPSDEDataSet();
  }

  getPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getPSDEDataSet();
    if (value == null) {
      throw new Error('未指定数据集对象');
    }
    return value;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  protected psthresholds: IPSThreshold[] | null = null;

  getPSThresholds(): IPSThreshold[] | null {
    if (this.psthresholds == null) {
      this.psthresholds = this.fillChildListModel(this.M.getPSThresholds, 'codelist.IPSThreshold') as IPSThreshold[];
    }
    return this.psthresholds;
  }

  get psThresholds(): IPSThreshold[] | null {
    return this.getPSThresholds();
  }

  findPSThreshold(objKey: any): IPSThreshold | null {
    return this.getPSModel5('codelist.IPSThreshold', this.getPSThresholds(), objKey) as IPSThreshold;
  }

  protected textpsdefield: IPSDEField | null = null;

  getTextPSDEField(): IPSDEField | null {
    if (this.textpsdefield != null) return this.textpsdefield;
    const value = this.M.getTextPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.textpsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.textpsdefield;
  }

  get textPSDEField(): IPSDEField | null {
    return this.getTextPSDEField();
  }

  getTextPSDEFieldMust(): IPSDEField {
    const value = this.getTextPSDEField();
    if (value == null) {
      throw new Error('未指定文本值存储属性');
    }
    return value;
  }

  get thresholdGroupTag(): string {
    return this.M.thresholdGroupTag;
  }

  get thresholdGroupTag2(): string {
    return this.M.thresholdGroupTag2;
  }

  get thresholdGroupType(): 'STATIC' | 'DYNAMIC' {
    return this.M.thresholdGroupType;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSThresholdGroupImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'codelist.IPSThresholdGroup') return true;
    return super.instanceof(cls);
  }
}
